﻿@{
    Layout = null;
}
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>仓库信息配置</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link href="~/Content/X-admin/css/font.css" rel="stylesheet" />
    <script src="~/Content/X-admin/lib/layui/layui.js"></script>
    <link href="~/Content/X-admin/css/xadmin.css" rel="stylesheet" />
    <script src="~/Content/X-admin/js/jquery.min.js"></script>
    <script src="~/Content/X-admin/js/xadmin.js"></script>
    <script src="~/Content/Scripts/System/systemFrame.js"></script>
    <script src="~/Content/Scripts/System/Common.js"></script>

</head>
<body>
    <div class="layui-fluid">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <div class="layui-card-body ">
                        <form class="layui-form layui-col-space5" name="qForm" id="qForm">
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="houseCode" placeholder="仓库编码" autocomplete="off" class="layui-input" id="houseCode">
                            </div>
                            <div class="layui-inline layui-show-xs-block">

                                <input type="text" name="houseName" placeholder="仓库名称" autocomplete="off" class="layui-input" id="houseName">
                            </div>

                            <div class="layui-inline layui-show-xs-block">
                                <button class="layui-btn" lay-filter="sreach" id="btn-view" type="button" onclick="loadData()"><i class="layui-icon">&#xe615;</i></button>
                            </div>
                        </form>
                    </div>
                    <div class="layui-card-header">
                       
                            <button class="layui-btn" id="btn-sync" type="button" onclick="Sync('wareHouse')"><i class="layui-icon">&#xe641;</i>数据同步</button>
                     
                       
                            <button class="layui-btn" id="btn-update" type="button" onclick="addData()"><i class="layui-icon"></i>新增仓库</button>
                       

                            <span style="margin-left: 20px; padding: 7px; background-color: #bababa;font-size:xx-small">数据停用</span>
                        </div>
                    <div class="layui-card-body layui-table-body layui-table-main" id="layui-table-main">
                        <table class="layui-hide" id="list" lay-filter="list"></table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

</html>
<script type="text/html" id="barDemo">
    <a title="货位信息" href="javascript:;" lay-event="view"><i class="layui-icon">&#xe857;</i></a>
    {{# if(d.isSync=='N'){}}
    <a title="编辑信息" href="javascript:;" lay-event="whEdit" id="update"><i class="layui-icon">&#xe642;</i></a>
    <a title="删除信息" href="javascript:;" lay-event="whDel" id="del"><i class="layui-icon">&#xe640;</i></a>
    {{# }}}

</script>
<script>
    /**
     * 加载数据
     * **/
    function loadData() {
        layui.use('table', function () {

            var conditon = JSON.stringify(FormToJson("qForm"));
            var table = layui.table;
            table.render({
                elem: '#list'
            , cols: [[ //标题栏
                { field: 'id', title: 'ID', width: 80 }
                , { field: 'houseCode', align: 'center', title: '仓库编码', width: '25%' }
                , { field: 'houseName', align: 'center', title: '仓库名称', width: '25%' }
                , { field: 'statusName', align: 'center', title: '数据状态', width: '24%' }
                , { field: 'isSyncName', align: 'center', title: '同步数据', width: '24%' }
                //, { title: '操作', width: '10%', align: 'center', toolbar: '#barDemo' }
            ]], done: function (res, curr, count) {
                $("[data-field='id']").css('display', 'none');//隐藏列
                $.each(res['data'], function (i, obj) {
                    var status = obj["status"];
                    if (status == "close") {
                        TableRowColor('layui-table-main', i, '#bababa');
                    }
                });
            }
            , url: "../Basis/GetDataList?dataType=wareHouse&condition=" + conditon
            , skin: 'row' //表格风格
            , even: true
            , page: true //是否显示分页
            , limits: [15, 20,30]
            , limit: 15 //每页默认显示的数量
            });
            //监听工具条
            table.on('tool(list)', function (obj) {
                var data = obj.data;
                if (obj.event == 'view') {
                    OpenPage(data.houseName + "-货位", "../Basis/WarePosition?wareCode=" + data.houseCode);
                }
                else if (obj.event == 'whEdit') {
                    if (data.isSync == 'Y') {
                        layer.msg("同步数据禁止修改！");
                    } else {
                        InfoOpenPage('../Basis/UpdateWareHouseInfo?dataId=' + data.id, data.houseName + '-信息修改', '65%', '80%')
                    }
                }
                else {
                    if (data.isSync == "Y") {
                        layer.msg("同步数据禁止删除！");
                    } else {
                        layer.confirm('确定删除此仓库？', function (index) {
                            $.ajax({
                                url: "../Basis/DelWareHouseInfo",
                                data: { dataId: data.id },
                                type: 'post',
                                success: function (rsl) {
                                    if (rsl.Result) {
                                        layer.msg('删除成功！');
                                    } else {
                                        layer.msg('删除失败！');
                                    }
                                    loadData()
                                }
                            })
                            layer.close('index')
                        })
                    }
                }

            });

        });
    }
    $(function () {
        WebPowersShow();
        loadData();
    })
    

    function addData() {
        InfoOpenPage('../Basis/UpdateWareHouseInfo?dataId=0', '新增仓库', '65%', '80%')
    }
</script>